package com.nineclock.approve.handler;

import com.alibaba.fastjson.JSONObject;
import com.nineclock.approve.utils.ActivitiUtils;
import com.nineclock.common.utils.UUIDUtils;
import org.activiti.bpmn.model.Process;
import org.activiti.bpmn.model.SequenceFlow;
import org.activiti.bpmn.model.StartEvent;
import org.springframework.stereotype.Component;

/**
 * 开始节点处理器
 */
@Component
public class StartNodeResolver extends ProcessNodeResolver{

    private static String type = "start"; // 节点类型

    @Override
    public boolean support(String nodeType) {
        return type.equals(nodeType);
    }

    @Override
    public void addFlowNodeToActiviti(Process process, JSONObject curNode, JSONObject nextNode) {
        // 创建开始节点
        StartEvent startEvent = new StartEvent();
        startEvent.setId(getNodeId(curNode));
        startEvent.setName(curNode.getString("name"));

        // 添加节点
        process.addFlowElement(startEvent);

        // 调用父类方法，绘制连线
        newSequenceFlow(process, curNode, nextNode);

    }


}
